package cn.fl.ref.fnovercollinfo.service.impl;

import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cmm.mid.core.framework.dto.DataResultDTO;
import cmm.mid.core.framework.page.Pager;
import cn.cmm.base.framework.constant.BaseExceptionConstant;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.utils.BaseLogUtils;
import cn.cmm.base.framework.utils.StringUtils;
import cn.fl.framework.base.context.CurrentThreadContext;
import cn.fl.ref.fnovercollinfo.service.IFncOverCollInfoService;
import cn.fl.ref.fnovercollinfo.transform.FncOverCollInfoVOTransform;
import cn.fl.ref.fnovercollinfo.vo.FncOverCollInfoVO;
import fl.flow.facade.flow.dto.FlowStartParamsDTO;
import fl.ref.fnovercollinfo.condition.FncOverCollInfoQueryCondition;
import fl.ref.fnovercollinfo.dto.FncOverCollInfoDTO;
import fl.ref.fnovercollinfo.service.IFncOverCollInfoApiService;
/**
 * @Description: 项目还款计划信息
 * @Description:业务层方法名称前缀：新增：add* 删除：remove* 修改：modify* 查询对象：select* get* 批量：batch* 查询集合：search*
 * 服务实现层
 */
@Service
public class FncOverCollInfoServiceImpl implements IFncOverCollInfoService {

	private static final Logger logger = LoggerFactory.getLogger(IFncOverCollInfoService.class);
	
	@Autowired
	private IFncOverCollInfoApiService  fncOverCollInfoApiService;

	@Override
	public FncOverCollInfoVO selectById(Long id) throws BaseException {
		if(StringUtils.isEmpty(id)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		};
		FncOverCollInfoDTO dto = this.fncOverCollInfoApiService.selectById(id);
		return FncOverCollInfoVOTransform.toVO(dto);
	}

	@Override
	public Long add(FncOverCollInfoVO entity) throws BaseException {
		if(null == entity){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		};
		//系统日志-有用户的情况下
		BaseLogUtils.info(logger, "add", "新增FncOverCollInfo数据.", CurrentThreadContext.getCurrentUserName());
		
		//系统日志-无用户的情况下
		BaseLogUtils.info(logger, "add", "新增FncOverCollInfo数据.");
		return this.fncOverCollInfoApiService.add(FncOverCollInfoVOTransform.toDTO(entity));
	}

	@Override
	public boolean removeById(Long id) throws BaseException {
		if(StringUtils.isEmpty(id)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		};
		return this.fncOverCollInfoApiService.removeById(id);
	}

	@Override
	public boolean modify(FncOverCollInfoVO entity) throws BaseException {
		if(null == entity){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		};
		return this.fncOverCollInfoApiService.modify(FncOverCollInfoVOTransform.toDTO(entity));
	}

	@Override
	public Pager searchListPage(Pager page) throws BaseException {
		if(null == page)page = new Pager();
		return this.fncOverCollInfoApiService.searchListPage(page);
	}
	

	@Override
	public List<FncOverCollInfoVO> searchList(FncOverCollInfoQueryCondition condition) {
		// TODO Auto-generated method stub
		return FncOverCollInfoVOTransform.toVOList(this.fncOverCollInfoApiService.searchList(condition))  ;
	}	

	/**
     * 超额抵押退回记录
     * @return
     */
    public Pager returnRecordPage(Pager page) throws BaseException{
      return this.fncOverCollInfoApiService.returnRecordPage(page);
    }

	@Override
	public DataResultDTO addFlowStart(FlowStartParamsDTO flowStartParamsDTO) {
		return this.fncOverCollInfoApiService.addFlowStart(flowStartParamsDTO);
	}

	/**
	 * 流程详细页面数据
	 * @return
	 */
	@Override
	public Map<String, Object> flowView(FncOverCollInfoQueryCondition condition) throws BaseException {
		return fncOverCollInfoApiService.flowView(condition);
	}
}
